package com.cs.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cs.domain.entity.UserInfo;
import com.cs.user.dao.IUserInfoDao;
import com.cs.user.service.IUserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserInfoServiceImpl implements IUserInfoService {

    @Autowired
    private IUserInfoDao infoDao;


    @Override
    public List<UserInfo> findAllUser() {
        return infoDao.selectList(null);
    }

    @Override
    public UserInfo findUserInfo(String username) {
        LambdaQueryWrapper<UserInfo> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserInfo::getUsername,username);
        List<UserInfo> list = infoDao.selectList(wrapper);
        UserInfo user = new UserInfo();
        if(list.size()!=0){
            user.setUsername(list.get(0).getUsername());
            user.setEmail(list.get(0).getEmail());
            return user;
        }else{
            return null;
        }

    }


}
